package io.renren.common.utils;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.List;

public abstract class ExportUtils {
    public static String exportExcel(List<String> titles, List<String[]> rows) throws IOException {

        File file = File.createTempFile("export", "xls");
        FileWriter fileWriter = new FileWriter(file);
        for (String title : titles) {
            fileWriter.write(title + "\t");
        }
        fileWriter.write("\n");
        for (String[] rowdata : rows) {
            for (String row : rowdata) {
                fileWriter.write(row + "\t");
            }
            fileWriter.write("\n");
        }
        fileWriter.close();
        return file.getAbsolutePath();

    }
}
